#include <bits/stdc++.h>
using namespace std;

// #define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
	{                                         \
		cerr << "\033[32;1m" << #x << " -> "; \
		err(x);                               \
	}
void err()
{
	cerr << "\033[39;0m" << endl;
}
template <typename T, typename... A>
void err(T a, A... x)
{
	cerr << a << ' ';
	err(x...);
}
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 1e5 + 50;

int fir[26], lst[26], nxt[N][26];

char s[N], t[N];

int main(int argc, char const *argv[])
{
	int tt;
	scanf("%d", &tt);
	for (int kk = 0; kk < tt; ++kk)
	{
		scanf("%s%s", s, t);
		int n = strlen(s), m = strlen(t);
		memset(fir, -1, sizeof fir);
		memset(lst, -1, sizeof lst);
		for (int i = 0; i < n; ++i)
			memset(nxt[i], -1, sizeof nxt[i]);
		for (int i = 0; i < n; ++i)
		{
			int id = s[i] - 'a';
			if (fir[id] == -1)
			{
				fir[id] = i;
				for (int j=0; j<=i; ++j)
					nxt[j][id] = i;
			}
			else
			{
				for (int j = lst[id] + 1; j <= i; ++j)
					nxt[j][id] = i;
			}
			lst[id] = i;
		}

		// for (int i = 0; i < n; ++i)
		// {
		// 	for (int j = 0; j < 5; ++j)
		// 		dbg(i, j, nxt[i][j]);
		// }
		int ans = 0, cur = -1;
		bool suc = true;
		for (int i = 0; i < m; ++i)
		{
			int id2 = t[i] - 'a';
			if (cur == -1)
			{
				if (fir[id2] == -1)
				{
					suc = false;
					break;
				}
				else
				{
					++ans;
					cur = fir[id2];
				}
			}
			else
			{
				if (cur+1 >= n || nxt[cur+1][id2] == -1)
				{
					--i;
					cur = -1;
				}
				else
				{
					cur = nxt[cur+1][id2];
				}
			}
			
			dbg(i, cur, ans);
		}
		if (!suc)
			puts("-1");
		else
			printf("%d\n", ans);
	}

	return 0;
}